package com.ruoyi.dzzh.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dzzh.domain.DzzhPc;
import com.ruoyi.dzzh.service.IDzzhPcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 排查情况Controller
 * 
 * @author ruoyi
 * @date 2022-05-11
 */
@RestController
@RequestMapping("/dzzh/pc")
public class DzzhPcController extends BaseController
{
    @Autowired
    private IDzzhPcService dzzhPcService;

    /**
     * 查询排查情况列表
     */
    @PreAuthorize("@ss.hasPermi('dzzh:pc:list')")
    @GetMapping("/list")
    public TableDataInfo list(DzzhPc dzzhPc)
    {
        startPage();
        List<DzzhPc> list = dzzhPcService.selectDzzhPcList(dzzhPc);
        return getDataTable(list);
    }

    /**
     * 导出排查情况列表
     */
    @PreAuthorize("@ss.hasPermi('dzzh:pc:export')")
    @Log(title = "排查情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzzhPc dzzhPc)
    {
        List<DzzhPc> list = dzzhPcService.selectDzzhPcList(dzzhPc);
        ExcelUtil<DzzhPc> util = new ExcelUtil<DzzhPc>(DzzhPc.class);
        util.exportExcel(response, list, "排查情况数据");
    }

    /**
     * 获取排查情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('dzzh:pc:query')")
    @GetMapping(value = "/{pcId}")
    public AjaxResult getInfo(@PathVariable("pcId") Long pcId)
    {
        return AjaxResult.success(dzzhPcService.selectDzzhPcByPcId(pcId));
    }

    /**
     * 新增排查情况
     */
    @PreAuthorize("@ss.hasPermi('dzzh:pc:add')")
    @Log(title = "排查情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzzhPc dzzhPc)
    {
        return toAjax(dzzhPcService.insertDzzhPc(dzzhPc));
    }

    /**
     * 修改排查情况
     */
    @PreAuthorize("@ss.hasPermi('dzzh:pc:edit')")
    @Log(title = "排查情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzzhPc dzzhPc)
    {
        return toAjax(dzzhPcService.updateDzzhPc(dzzhPc));
    }

    /**
     * 删除排查情况
     */
    @PreAuthorize("@ss.hasPermi('dzzh:pc:remove')")
    @Log(title = "排查情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pcIds}")
    public AjaxResult remove(@PathVariable Long[] pcIds)
    {
        return toAjax(dzzhPcService.deleteDzzhPcByPcIds(pcIds));
    }
}
